<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>FreezeThaw - converting Perl structures to strings and back. - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of FreezeThaw - MetaCPAN" href="https://metacpan.org/dist/FreezeThaw/releases.rss" />
        <link rel="canonical" href="FreezeThaw.html" />
        <meta name="description" content="converting Perl structures to strings and back." />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/FreezeThaw" />
<meta name="twitter:title"       content="FreezeThaw" />
<meta name="twitter:description" content="converting Perl structures to strings and back." />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="FreezeThaw.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of FreezeThaw was released.">
      <span class="relatize">03 Apr 2010 22:28:52 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/FreezeThaw">FreezeThaw</a>
  </li>
  <li>
    Module version: 0.5001
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/FreezeThaw/source/FreezeThaw.pm">Source</a>
    (<a href="https://metacpan.org/dist/FreezeThaw/source/FreezeThaw.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/FreezeThaw/source">Browse</a>
    (<a href="https://metacpan.org/dist/FreezeThaw/source?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/FreezeThaw/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/FreezeThaw/contribute">How to Contribute</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=FreezeThaw">Issues</a>
      (5)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=FreezeThaw+0.5001" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/F/FreezeThaw.html?oncpan=1&amp;distmat=1&amp;version=0.5001&amp;grade=2" style="color: #090">867</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/F/FreezeThaw.html?oncpan=1&amp;distmat=1&amp;version=0.5001&amp;grade=3" style="color: #900">1</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/F/FreezeThaw.html?oncpan=1&amp;distmat=1&amp;version=0.5001&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/ILYAZ/FreezeThaw-0.5001">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on FreezeThaw who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 2
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/FreezeThaw-0.5001/index.html">79.16% Coverage </a>
    </li>
    <li>
      License: unknown
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/FreezeThaw/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/I/IL/ILYAZ/modules/FreezeThaw-0.5001.tar.gz">
      Download (<span itemprop="fileSize">11.52KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FILYAZ%2FFreezeThaw-0.5001%2FFreezeThaw.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/FreezeThaw/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/FreezeThaw/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:FreezeThaw">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="FreezeThaw">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/FreezeThaw.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="ILYAZ/FreezeThaw-0.5001"
>0.5001
  (ILYAZ on 2010-04-03)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.50"
>0.50
  (ILYAZ on 2010-03-07)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.45"
>0.45
  (ILYAZ on 2009-02-10)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.44"
>0.44
  (ILYAZ on 2009-02-08)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.43"
>0.43
  (ILYAZ on 2002-03-30)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.41"
>0.41
  (ILYAZ on 2000-05-05)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.4"
>0.4
  (ILYAZ on 2000-05-05)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.3"
>0.3
  (ILYAZ on 1996-10-28)</option>
<optgroup label="BackPAN">'
<option
  
  value="ILYAZ/FreezeThaw-0_2"
>0_2
  (ILYAZ on 1996-05-02)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/ILYAZ/FreezeThaw-0.5001/diff/' + encodeURIComponent(this.value) + '/FreezeThaw.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="ILYAZ/FreezeThaw-0.5001"
>0.5001
  (ILYAZ on 2010-04-03)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.50"
>0.50
  (ILYAZ on 2010-03-07)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.45"
>0.45
  (ILYAZ on 2009-02-10)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.44"
>0.44
  (ILYAZ on 2009-02-08)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.43"
>0.43
  (ILYAZ on 2002-03-30)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.41"
>0.41
  (ILYAZ on 2000-05-05)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.4"
>0.4
  (ILYAZ on 2000-05-05)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.3"
>0.3
  (ILYAZ on 1996-10-28)</option>
<optgroup label="BackPAN">'
<option
  
  value="ILYAZ/FreezeThaw-0_2"
>0_2
  (ILYAZ on 1996-05-02)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><i class="ttip" title="dynamic_config enabled">unknown</i></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/FreezeThaw/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=FreezeThaw">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=FreezeThaw">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/ILYAZ/FreezeThaw-0.5001/view/FreezeThaw.pm">This version</a>
    </li>
    <li>
      <a href="FreezeThaw.html">Latest version</a>
    </li>
    <li>
    </li>
    <li>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/ILYAZ" class="author-name">Ilya Zakharevich</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/FreezeThaw.pm&#39;" class="">
<option
  selected
  value="ILYAZ/FreezeThaw-0.5001"
>0.5001
  (ILYAZ on 2010-04-03)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.50"
>0.50
  (ILYAZ on 2010-03-07)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.45"
>0.45
  (ILYAZ on 2009-02-10)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.44"
>0.44
  (ILYAZ on 2009-02-08)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.43"
>0.43
  (ILYAZ on 2002-03-30)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.41"
>0.41
  (ILYAZ on 2000-05-05)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.4"
>0.4
  (ILYAZ on 2000-05-05)</option>
<option
  
  value="ILYAZ/FreezeThaw-0.3"
>0.3
  (ILYAZ on 1996-10-28)</option>
<optgroup label="BackPAN">'
<option
  
  value="ILYAZ/FreezeThaw-0_2"
>0_2
  (ILYAZ on 1996-05-02)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/FreezeThaw">FreezeThaw-0.5001</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage two &#10;
          • 9 direct dependents &#10;          • 17 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="FreezeThaw-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="FreezeThaw-0.5001">
    <input type="hidden" name="author" value="ILYAZ">
    <input type="hidden" name="distribution" value="FreezeThaw">
    <button type="submit" class="favorite"><span></span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="FreezeThaw.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite">
<span></span> ++</a>
</div>
   / <span>FreezeThaw</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="FreezeThaw.html#NAME">NAME</a></li>
  <li><a href="FreezeThaw.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="FreezeThaw.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="FreezeThaw.html#EXPORT">EXPORT</a></li>
  <li><a href="FreezeThaw.html#User-API">User API</a></li>
  <li><a href="FreezeThaw.html#Developer-API">Developer API</a>
    <ul>
      <li><a href="FreezeThaw.html#Instantiating">Instantiating</a></li>
    </ul>
  </li>
  <li><a href="FreezeThaw.html#BUGS-and-LIMITATIONS">BUGS and LIMITATIONS</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>FreezeThaw - converting Perl structures to strings and back.</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>  use FreezeThaw qw(freeze thaw cmpStr safeFreeze cmpStrHard);
  $string = freeze $data1, $data2, $data3;
  ...
  ($olddata1, $olddata2, $olddata3) = thaw $string;
  if (cmpStr($olddata2,$data2) == 0) {print &quot;OK!&quot;}</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>Converts data to/from stringified form, appropriate for saving-to/reading-from permanent storage.</p>

<p>Deals with objects, circular lists, repeated appearence of the same refence. Does not deal with overloaded <i>stringify</i> operator yet.</p>

<h1 id="EXPORT">EXPORT</h1>

<dl>

<dt id="Default">Default</dt>
<dd>

<p>None.</p>

</dd>
<dt id="Exportable">Exportable</dt>
<dd>

<p><code>freeze thaw cmpStr cmpStrHard safeFreeze</code>.</p>

</dd>
</dl>

<h1 id="User-API"><a id="User"></a>User API</h1>

<dl>

<dt id="cmpStr"><code>cmpStr</code></dt>
<dd>

<p>analogue of <code>cmp</code> for data. Takes two arguments and compares them as separate entities.</p>

</dd>
<dt id="cmpStrHard"><code>cmpStrHard</code></dt>
<dd>

<p>analogue of <code>cmp</code> for data. Takes two arguments and compares them considered as a group.</p>

</dd>
<dt id="freeze"><code>freeze</code></dt>
<dd>

<p>returns a string that encupsulates its arguments (considered as a group). <code>thaw</code>ing this string leads to a fatal error if arguments to <code>freeze</code> contained references to <code>GLOB</code>s and <code>CODE</code>s.</p>

</dd>
<dt id="safeFreeze"><code>safeFreeze</code></dt>
<dd>

<p>returns a string that encupsulates its arguments (considered as a group). The result is <code>thaw</code>able in the same process. <code>thaw</code>ing the result in a different process should result in a fatal error if arguments to <code>safeFreeze</code> contained references to <code>GLOB</code>s and <code>CODE</code>s.</p>

</dd>
<dt id="thaw"><code>thaw</code></dt>
<dd>

<p>takes one string argument and returns an array. The elements of the array are &quot;equivalent&quot; to arguments of the <code>freeze</code> command that created the string. Can result in a fatal error (see above).</p>

</dd>
</dl>

<h1 id="Developer-API"><a id="Developer"></a>Developer API</h1>

<p><code>FreezeThaw</code> <code>freeze</code>s and <code>thaw</code>s data blessed in some package by calling methods <code>Freeze</code> and <code>Thaw</code> in the package. The fallback methods are provided by the <code>FreezeThaw</code> itself. The fallback <code>Freeze</code> freezes the &quot;content&quot; of blessed object (from Perl point of view). The fallback <code>Thaw</code> blesses the <code>thaw</code>ed data back into the package.</p>

<p>So the package needs to define its own methods only if the fallback methods will fail (for example, for a lot of data the &quot;content&quot; of an object is an address of some <b>C</b> data). The methods are called like</p>

<pre><code>  $newcooky = $obj-&gt;Freeze($cooky);
  $obj = Package-&gt;Thaw($content,$cooky);</code></pre>

<p>To save and restore the data the following method are applicable:</p>

<pre><code>  $cooky-&gt;FreezeScalar($data,$ignorePackage,$noduplicate);</code></pre>

<p>during Freeze()ing, and</p>

<pre><code>  $data = $cooky-&gt;ThawScalar;</code></pre>

<p>Two optional arguments $ignorePackage and $noduplicate regulate whether the freezing should not call the methods even if $data is a reference to a blessed object, and whether the data should not be marked as seen already even if it was seen before. The default methods</p>

<pre><code>  sub UNIVERSAL::Freeze {
    my ($obj, $cooky) = (shift, shift);
    $cooky-&gt;FreezeScalar($obj,1,1);
  }

  sub UNIVERSAL::Thaw {
    my ($package, $cooky) = (shift, shift);
    my $obj = $cooky-&gt;ThawScalar;
    bless $obj, $package;
  }</code></pre>

<p>call the <code>FreezeScalar</code> method of the $cooky since the freezing engine will see the data the second time during this call. Indeed, it is the freezing engine who calls UNIVERSAL::Freeze(), and it calls it because it needs to freeze $obj. The above call to $cooky-&gt;FreezeScalar() handles the same data back to engine, but because flags are different, the code does not cycle.</p>

<p>Freezing and thawing $cooky also allows the following additional methods:</p>

<pre><code>  $cooky-&gt;isSafe;</code></pre>

<p>to find out whether the current freeze was initiated by <code>freeze</code> or <code>safeFreeze</code> command. Analogous method for thaw $cooky returns whether the current thaw operation is considered safe (i.e., either does not contain cached elsewhere data, or comes from the same application). You can use</p>

<pre><code>  $cooky-&gt;makeSafe;</code></pre>

<p>to prohibit cached data for the duration of the rest of freezing or thawing of current object.</p>

<p>Two methods</p>

<pre><code>  $value = $cooky-&gt;repeatedOK;
  $cooky-&gt;noRepeated;           # Now repeated are prohibited</code></pre>

<p>allow to find out/change the current setting for allowing repeated references.</p>

<p>If you want to flush the cache of saved objects you can use</p>

<pre><code>  FreezeThaw-&gt;flushCache;</code></pre>

<p>this can invalidate some frozen string, so that thawing them will result in fatal error.</p>

<h2 id="Instantiating">Instantiating</h2>

<p>Sometimes, when an object from a package is recreated in presense of repeated references, it is not safe to recreate the internal structure of an object in one step. In such a situation recreation of an object is carried out in two steps: in the first the object is <code>allocate</code>d, in the second it is <code>instantiate</code>d.</p>

<p>The restriction is that during the <i>allocation</i> step you cannot use any reference to any Perl object that can be referenced from any other place. This restriction is applied since that object may not exist yet.</p>

<p>Correspondingly, during <i>instantiation</i> step the previosly <i>allocated</i> object should be <code>filled</code>, i.e., it can be changed in any way such that the references to this object remain valid.</p>

<p>The methods are called like this:</p>

<pre><code>  $pre_object_ref = Package-&gt;Allocate($pre_pre_object_ref);
        # Returns reference
  Package-&gt;Instantiate($pre_object_ref,$cooky);
        # Converts into reference to blessed object</code></pre>

<p>The reverse operations are</p>

<pre><code>  $object_ref-&gt;FreezeEmpty($cooky);
  $object_ref-&gt;FreezeInstance($cooky);</code></pre>

<p>during these calls object can <code>freezeScalar</code> some information (in a usual way) that will be used during <code>Allocate</code> and <code>Instantiate</code> calls (via <code>thawScalar</code>). Note that the return value of <code>FreezeEmpty</code> is cached during the phase of creation of uninialized objects. This <b>must</b> be used like this: the return value is the reference to the created object, so it is not destructed until other objects are created, thus the frozen values of the different objects will not share the same references. Example of bad result:</p>

<pre><code>  $o1-&gt;FreezeEmpty($cooky)</code></pre>

<p>freezes <code>{}</code>, and <code>$o2-&gt;FreezeEmpty($cooky)</code> makes the same. Now nobody guaranties that that these two copies of <code>{}</code> are different, unless a reference to the first one is preserved during the call to <code>$o2-&gt;FreezeEmpty($cooky)</code>. If <code>$o1-&gt;FreezeEmpty($cooky)</code> returns the value of <code>{}</code> it uses, it will be preserved by the engine.</p>

<p>The helper function <code>FreezeThaw::copyContents</code> is provided for simplification of instantiation. The syntax is</p>

<pre><code>  FreezeThaw::copyContents $to, $from;</code></pre>

<p>The function copies contents the object $from point to into what the object $to points to (including package for blessed references). Both arguments should be references.</p>

<p>The default methods are provided. They do the following:</p>

<dl>

<dt id="FreezeEmpty"><code>FreezeEmpty</code></dt>
<dd>

<p>Freezes an <i>empty</i> object of underlying type.</p>

</dd>
<dt id="FreezeInstance"><code>FreezeInstance</code></dt>
<dd>

<p>Calls <code>Freeze</code>.</p>

</dd>
<dt id="Allocate"><code>Allocate</code></dt>
<dd>

<p>Thaws what was frozen by <code>FreezeEmpty</code>.</p>

</dd>
<dt id="Instantiate"><code>Instantiate</code></dt>
<dd>

<p>Thaws what was frozen by <code>FreezeInstance</code>, uses <code>copyContents</code> to transfer this to the $pre_object.</p>

</dd>
</dl>

<h1 id="BUGS-and-LIMITATIONS"><a id="BUGS"></a>BUGS and LIMITATIONS</h1>

<p>A lot of objects are blessed in some obscure packages by XSUB typemaps. It is not clear how to (automatically) prevent the <code>UNIVERSAL</code> methods to be called for objects in these packages.</p>

<p>The objects which can survive freeze()/thaw() cycle must also survive a change of a &quot;member&quot; to an equal member. Say, after</p>

<pre><code>  $a = [a =&gt; 3];
  $a-&gt;{b} = \ $a-&gt;{a};</code></pre>

<p>$a satisfies</p>

<pre><code>  $a-&gt;{b} == \ $a-&gt;{a}</code></pre>

<p>This property will be broken by freeze()/thaw(), but it is also broken by</p>

<pre><code>  $a-&gt;{a} = delete $a-&gt;{a};</code></pre></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install FreezeThaw, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm FreezeThaw</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install FreezeThaw</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="FreezeThaw.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
